Socket
Socket
Sign inDemoInstall

html-encoding-sniffer

Package Overview
Dependencies
Maintainers
6
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-encoding-sniffer

Sniff the encoding from a HTML byte stream


Version published
Maintainers
6
Created

What is html-encoding-sniffer?

The html-encoding-sniffer npm package is designed to determine the encoding of HTML documents. It does this by examining the byte stream of the document, looking for any encoding declarations in the form of a meta tag or an HTTP header. This is particularly useful for applications that need to correctly interpret or display HTML content from various sources, ensuring that text is properly encoded and displayed.

What are html-encoding-sniffer's main functionalities?

Sniffing HTML encoding from HTTP headers

This feature allows you to determine the encoding of an HTML document by examining the HTTP headers. The 'transportLayerEncodingLabel' option is used to specify the encoding declared in the HTTP headers.

"use strict";
const htmlEncodingSniffer = require('html-encoding-sniffer');
const encoding = htmlEncodingSniffer(byteStream, { transportLayerEncodingLabel: 'utf-8' });

Sniffing HTML encoding from a meta tag

This feature enables the detection of the document's encoding by looking for a meta tag within the HTML that specifies the encoding. The 'defaultEncoding' option allows you to specify a fallback encoding in case no encoding is declared in the document.

"use strict";
const htmlEncodingSniffer = require('html-encoding-sniffer');
const encoding = htmlEncodingSniffer(byteStream, { defaultEncoding: 'windows-1252' });

Other packages similar to html-encoding-sniffer

Keywords

FAQs

Package last updated on 18 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc